package com.study.talk.module.mapper;

import com.study.talk.module.entity.Friend;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.study.talk.module.entity.UserInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author thor
 * @since 2023-12-18
 */
@Mapper
public interface FriendMapper extends BaseMapper<Friend> {

    @Delete("delete from friend where user_id = #{userId} and friend_id = #{friendId}")
    void removeFriend(Integer userId,Integer friendId);

    @Delete("delete from friend where user_id = #{userId}")
    void removeAllFriend(Integer userId);

    @Select("select * from friend where  user_id=#{userId} and friend_id=#{friendId}")
    Friend queryIsFriend(Integer userId,Integer friendId);

    @Select("select * from friend where  user_id=#{userId} ")
    List<Friend> getFriendList(Integer userId);

    @Select("SELECT b.* FROM friend as a,user_info as b WHERE a.user_id=#{userId} AND a.friend_id=b.id")
    List<UserInfo> getUserInfoList(Integer userId);
}
